#ifndef HELLOWINDOW_H
#define HELLOWINDOW_H

#include <QWindow>
#include <QOpenGLFunctions_3_3_Core>
#include <QOpenGLVertexArrayObject>
#include <QOpenGLShaderProgram>
#include <QOpenGLBuffer>
#include <QOpenGLTexture>

class HelloWindow : public QWindow, protected QOpenGLFunctions_3_3_Core
{
public:
    HelloWindow();
    ~HelloWindow() override;

    bool event(QEvent *event) override;

public slots:
    void renderNow();
    void renderLater();

protected:
    void exposeEvent(QExposeEvent *event) override;
    void resizeEvent(QResizeEvent *event) override;
    void keyPressEvent(QKeyEvent *event) override;
    void keyReleaseEvent(QKeyEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;
    void wheelEvent(QWheelEvent *event) override;

private:
    QOpenGLContext *m_context;
    QOpenGLShaderProgram *m_program;
    bool m_update_pending;

    QOpenGLVertexArrayObject *m_vao;
    QOpenGLBuffer *m_vbo;
    QOpenGLTexture *m_texture[2];

    QVector3D m_cameraPos;
    QVector3D m_cameraFront;
    QVector3D m_cameraUp;

    float m_deltaTime;
    float m_lastFrame;

    int m_leftRight[2];
    int m_upDown[2];
    void pushDirectory(int array[2], int value);
    void popDirectory(int array[2], int value);

    QPoint m_lastPoint;
    float m_yaw;
    float m_pitch;
    float m_fov;
};

#endif // HELLOWINDOW_H
